#
# Simple date parsing stuff
#

import datetime
import unittest

class DateParser(object):
    def init(self):
        pass
    
    def parseDate(self, dateString):
        """
        Parse a string in the format that the google calendar api returns
        eg: "2009-01-15T13:15:00.000-04:00"
        """
        dateUpToSeconds = dateString.split(".")[0]
        return datetime.datetime.strptime(dateUpToSeconds, "%Y-%m-%dT%H:%M:%S")
    
    
class DateParserTests(unittest.TestCase):
    def testDateParser(self):
        dateParser = DateParser()
        #date = dateParser.parseDate("2009-01-15T13:15:00.000-04:00")
        date = dateParser.parseDate("2009-01-15T13:15:23.000-04:00")
        self.assertEquals(date.year, 2009)
        self.assertEquals(date.month, 1)
        self.assertEquals(date.day, 15)
        self.assertEquals(date.second, 23)
